import React, { Component } from 'react';
import Taro from '@tarojs/taro';
import { View, Text, Button, Image } from '@tarojs/components';
import { Cell } from '@antmjs/vantui';
import "./index.scss"
import { walletPersonCerti } from '@/services/api/wallet';
import {  formatDate, parseDateFromStr } from '@/utils/fomatter';

class WalletRealName extends Component {

    config = {
        navigationBarTitleText: ''
    }

    state = {
        userInfo:{}
    }

    componentWillMount() {
        this.requestData();
     }
    componentDidMount() { }
    componentWillReceiveProps(nextProps, nextContext) { }
    componentWillUnmount() { }

    onbackList() {
        Taro.navigateBack();
    }


    requestData(){
        walletPersonCerti().then((resp) => {
           if(resp.code === 200){
                this.setState({userInfo:resp.data})
           }
        })
    }


    render() {

        const renderLeftArea = ({ iconName, name }) => {
            return (
                <View className='left-area'>
                    <View className="title">{name}</View>
                </View>
            )
        }

        const renderRightIconArea = (name) => {
            return (
                <Text>{name}</Text>
            )
        }

        const { statusBarHeight, } = Taro.getSystemInfoSync()
        const { userInfo }  =  this.state

        return (
            <View className='page'>
                <View className='nav' style={{ marginTop: statusBarHeight }}>
                    <View className='nav-back' onClick={() => this.onbackList()} >
                        <Image src={require("@/assets/icons/public/nav_back_white.svg")} style='height:24px;width:24px;'></Image>
                    </View>
                    <View className='nav_right' ></View>
                </View>
                <View className='page-top' style={{ marginTop: statusBarHeight + 44 + 8, }}>
                     <Image src={require("@/assets/images/wallet-realname-top.png")} style='height:88px;width:159px;'></Image>
                    <Text className='desc'>实名信息</Text>
                </View>
                <View className='page-list'>
                    <Cell title={'真实信息'}  value={userInfo['name'] } titleStyle={{ fontSize: '16px' }} border={true}  />
                    <Cell title={'性别'}  value={userInfo['sex'] } titleStyle={{ fontSize: '16px' }} border={true}  />
                    <Cell title={'身份证号'}  value={userInfo['credCode'] } titleStyle={{ fontSize: '16px' }} border={true}  />
                    <Cell title={'出生日期'}  value={userInfo['bithday'] } titleStyle={{ fontSize: '16px' }} border={true}  />
                    <Cell title={'Hash'}  value={userInfo['txHash'] } titleStyle={{ fontSize: '16px' }} border={true}  />
                    <Cell title={'上链时间'}  value={formatDate(userInfo['upchainTime'],null,'YYYY-MM-DD')  } titleStyle={{ fontSize: '16px' }} border={true}  />
                </View>
            </View>
        );
    }
}


export default WalletRealName;